//
//  MainViewController.swift
//  lixiangweibo
//
//  Created by dyy on 15/11/23.
//  Copyright © 2015年 lixianggongzuoshi. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewControllers()

    }
    //private 表示私有的
    
 private func addChildViewControllers() {
    //设置tabBar颜色
        tabBar.tintColor = UIColor.orangeColor()
    //设置子控制器
        addChildViewController("Home", title: "首页", imageName: "tabbar_home")
        addChildViewController("Message", title: "消息", imageName: "tabbar_message_center")
        addChildViewController("Discover", title: "发现", imageName: "tabbar_discover")
        addChildViewController("Profile", title: "我", imageName: "tabbar_profile")
    }
    //添加子控制器
 private func  addChildViewController(sbName: NSString,title: NSString ,imageName: NSString ) {
        //
        let sb = UIStoryboard(name: sbName as String, bundle: nil)
        let nva = sb.instantiateInitialViewController() as! UINavigationController
        //nva.title = title as String
        nva.topViewController?.title = title as String
        nva.tabBarItem.image = UIImage(named: imageName as String)
        nva.tabBarItem.selectedImage = UIImage(named: (imageName as String) + "_highlighted")
    
        addChildViewController(nva)
    }



}
